function mode_deptclass(){
	
	var c={
		showdept:function(){
			if($('#showdept').html()==''){
				this.reloaduser();
			}else{
			}
		},
		reloaduser:function(){
			$('#showdept').html('');
			$('#leftshow1ss').remove();
			this.showuserlists(0,0, 'showdept');
			this.showgroup();
	
			$('#leftshow1').append('<div id="leftshow1ss" align="center" style="padding:10px;"><a onclick="reim.deptreload(this)" style="font-size:12px;color:#bbbbbb"><i class="icon-refresh"></i> 刷新</a></div>');
		},
		showuserlists:function(pid,xu, svie){
			var o = $('#'+svie+'');
			var tx= o.text();
			if(tx){if(pid!=0){o.toggle();}return;}
			var a =this.useraarr,i,len=a.length,d,dn,s='',wfj,zt,sids;
			for(i=0;i<len;i++){
				d=a[i];
				sids = ',-1,';
				if(pid==d.deptid || sids.indexOf(','+pid+',')>-1){
					zt='';
					if(d.status==0)zt='&nbsp;<font style="font-size:12px" color=red>未加入</font>';
					s='<div class="lists" onclick="reim.showuserinfo('+i+')" style="padding-left:'+(xu*20+10)+'px" >';
					s+='<table cellpadding="0" border="0" width="100%"><tr>';
					s+='<td style="padding-right:5px"><div style="height:24px;overflow:hidden"><img src="'+d.face+'" style="height:24px;width:24px"></div></td>';
					s+='<td align="left" width="100%"><div class="name">'+d.name+''+zt+'</div></td>';
					s+='</tr></table>';
					s+='</div>';
					o.append(s);
				}
			}
			
			a = this.deptarr;
			len=a.length;
			for(i=0;i<len;i++){
				d = a[i];
				if(d.pid==pid){
					wfj = 'icon-folder-close-alt';
					s='<div class="lists" style="padding-left:'+(xu*20+10)+'px" onclick="reim.showuserlists('+d.id+','+(xu+1)+',\'showdept_'+d.id+'\')">';
					s+='	<i class="'+wfj+'"></i> '+d.name+'';
					if(d.ntotal>0)s+=' <span style="font-size:12px;color:#888888">('+d.ntotal+')</span>';
					s+='</div>';
					s+='<span id="showdept_'+d.id+'"></span>';
					o.append(s);
					if(xu==0)this.showuserlists(d.id, xu+1, 'showdept_'+d.id+'');
				}
			}
		},
		showuserinfo:function(oi){
			this.addtabs('userinfo'+oi+'','webmain/reim/index/zye_userinfo.html?oi='+oi+'');
		},
		showmyinfo:function(){
			if(useraid=='0')return;
			var a =this.useraarr,i,len=a.length;
			for(i=0;i<len;i++){
				if(a[i].id==useraid){
					this.showuserinfo(i);
					return;
				}
			}
		},
		openchat:function(oi){
			var d = this.useraarr[oi];
			var num = 'achat'+d.id+'';
			var da  = this.historysdata[num];
			if(!da){
				da={
					'type':'achat',
					'num' : num,
					'id':d.id,
					name:d.name,
					face:d.face,
					stotal:0,
					cont:'',
					optdt:js.serverdt()
				}
				this.showhistorys(da);
			}
			this.showchat(num);
		},
		deptreload:function(o1){
			if(o1)o1.innerHTML='<img src="images/loading.gif">';
			this.ajax('reim,getdept',false,function(ret){
				reim.deptreloads(ret.data);
			});
		},
		deptreloads:function(ret){
			this.deptarr=ret.deptarr;
			this.useraarr=ret.useraarr;
			this.grouparr=ret.grouparr;
			this.reloaduser();
		},
		showgroup:function(){
			$('#showgroupdiv').append('');
			var a=this.grouparr,i,len=a.length;
			for(i=0;i<len;i++){
				this.showgroupss(a[i]);
			}
			$('#showgroupdivs').html('会话('+len+')');
		},
		showgroupss:function(d){
			var num = 'group_'+d.num+'';
			$('#lists_'+num+'').remove();
			var hei = 26,str=this.chatlabel(d.receid);
			var s	= '<div class="lists" onclick="reim.opengroup('+d.id+')" id="lists_'+num+'" >';
			s+='<table cellpadding="0" border="0" width="100%"><tr>';
			s+='<td style="padding-right:8px"><div style="height:'+hei+'px;overflow:hidden"><img style="height:'+hei+'px;width:'+hei+'px" src="'+d.picurl+'"></div></td>';
			s+='<td align="left" width="100%"><div class="name"><font>'+d.name+'</font> '+str+'</div></td>';
			s+='<td align="right" nowrap>&nbsp;</td>';
			s+='</tr></table>';
			s+='</div>';
			
			$('#showgroupdiv').append(s);
		},
		opengroup:function(oi){
			var a = this.grouparr;
			var i,len=a.length,d=false;
			for(i=0;i<len;i++){
				if(a[i].id==oi){
					d=a[i];
					break;
				}
			}
			if(!d)return;
			var num = 'agroup'+d.id+'';
			var da  = this.historysdata[num];
			if(!da){
				da={
					'type':'agroup',
					'num' : num,
					'id':d.id,
					name:d.name,
					face:d.picurl,
					receid:d.receid,
					renshu:d.renshu,
					names:this.chatlabel(d.receid),
					stotal:0,
					cont:'',
					optdt:js.serverdt()
				}
				this.showhistorys(da,true);
			}
			this.showchat(num);
			this.changleft(0);
		},
		showgroupuser:function(gid){
			js.tanbody('viewshoe','查看人员',500,400,{
				html:'<div id="showviewsuser" style="height:300px;overflow:auto"><div style="padding:5px"><img src="images/mloading.gif"></div></div>'
			});
			this.ajax('chat,getuser',{chatid:gid},function(ret){
				reim.viewkusershow(ret.data);
			});
		},
		viewkusershow:function(ret){
			var a = ret.useraarr,i,len=a.length,s='',oi=0,s1;
			var rs= ret.chatinfo;
			this.lengchang = 0;
			s='<table ><tr>';
			for(i=0;i<len;i++){
				oi++;
				s1='';
				if(!rs.receid && rs.createid==useraid && rs.createid!=a[i].id)s1='reim.removegroupuser('+rs.id+','+a[i].id+',this)';
				s+='<td style="padding:10px" onclick="'+s1+'" align="center"><img src="'+a[i].face+'" class="face" style="width:40px;height:40px"><br>';
				if(rs.createid==a[i].id)s+='<font color="'+maincolor+'"><i title="创建者" class="icon-user"></i></font>';
				s+=''+a[i].name+'</td>';
				if(oi%8==0)s+='</tr><tr>';
			}
			this.lengchang = oi;
			s+='</tr></table>';
			$('#msgview_viewshoe').html('共'+oi+'人');
			$('#showviewsuser').html(s);
		},
		removegroupuser:function(gid,aid,o1){
			js.confirm('确定要把此人从会话中删除吗？',function(jg){
				if(jg=='yes'){
					$(o1).remove();
					reim.lengchang--;
					chatobj['agroup'+gid+''].rerenshu(reim.lengchang);
					$('#msgview_viewshoe').html('共'+reim.lengchang+'人');
					reim.ajax('chat,removeuser',{chatid:gid,aid:aid});
				}
			});
		},
		createchat:function(){
			js.prompt('请输入会话名称',function(jg,txt){
				if(jg=='yes' && txt){
					js.loading('创建中...');
					reim.ajax('chat,create',{name:txt},function(ret){
						js.msgok('创建成功');
						reim.createchats(ret.data, true);
					});
				}
			},'创建会话');
		},
		createchats:function(ret, ob){
			this.grouparr=ret.grouparr;
			this.showgroup();
			if(ob)this.opengroup(ret.newid);
		}
	}
	
	return c;
}